package com.ad.pet.app.mall.adapter;

import android.app.Activity;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ad.pet.MainActivity;
import com.ad.pet.R;
import com.ad.pet.app.Navigation;
import com.ad.pet.app.main.adapter.HomeTypeItemAdapter;
import com.ad.pet.common.data.utils.glide.GlideUtil;
import com.ad.pet.models.remote.home.HomeProduce;

import java.util.List;

/**
 * Created by SEELE on 2018/3/27.
 */

public class GoodDetailAdapter extends BaseQuickAdapter<HomeProduce, BaseViewHolder> {

    public GoodDetailAdapter( @Nullable List<HomeProduce> data) {
        super(R.layout.item_mall_recycler, data);
    }

    @Override
    protected void convert(BaseViewHolder helper,final HomeProduce item) {
        ImageView imageView = helper.getView(R.id.iv_top);
        RecyclerView recyclerView = helper.getView(R.id.recycler_view);
        GlideUtil.load(mContext,item.getImg_url(),imageView);
        recyclerView.setLayoutManager(new LinearLayoutManager(mContext,LinearLayoutManager.HORIZONTAL,false));
        recyclerView.setAdapter(new HomeTypeItemAdapter(R.layout.item_home_type_content_mall,item.getItem_list()));
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Navigation.goCommonWebView((Activity) mContext,item.getTitle(),item.getSearch_url(),false, MainActivity.REQUEST_GO_MALL);
            }
        });


    }


}
